{% set default_cable = '5m' %}
{% set ingress_lossless_pool_size = '43067728' %}
{% set ingress_lossy_pool_size = '3520000' %}
{% set egress_lossless_pool_size = '46749824' %}
{% set egress_lossy_pool_size = '2463824' %}

{%- macro generate_port_lists(PORT_ALL) %}
    {# Generate list of ports #}
    {%- for port_idx in range(0, 32) %}
        {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{%- endif %}
    {%- endfor %}
{%- endmacro %}

{%- macro generate_buffer_pool_and_profiles() %}
    "BUFFER_POOL": {
        "ingress_lossless_pool": {
            "size": "{{ ingress_lossless_pool_size }}",
            {%- if dynamic_mode is defined %}
            "xoff": "3153920",
            {%- endif %}
            "type": "ingress",
            "mode": "dynamic"
        },
        "ingress_lossy_pool": {
            "size": "{{ ingress_lossy_pool_size }}",
            "type": "ingress",
            "mode": "dynamic"
        },
        "egress_lossless_pool": {
            "size": "{{ egress_lossless_pool_size }}",
            "type": "egress",
            "mode": "dynamic"
        },
        "egress_lossy_pool": {
            "size": "{{ egress_lossy_pool_size }}",
            "type": "egress",
            "mode": "dynamic"
        }
    },
    "BUFFER_PROFILE": {
        "ingress_lossy_profile": {
            "pool":"ingress_lossy_pool",
            "size":"4096",
            "dynamic_th":"3"
        },
        "egress_lossless_profile": {
            "pool":"egress_lossless_pool",
            "size":"0",
            "dynamic_th":"7"
        },
        "egress_lossy_profile": {
            "pool":"egress_lossy_pool",
            "size":"4096",
            "dynamic_th":"3"
        },
        "q_lossy_profile": {
            "pool":"egress_lossy_pool",
            "size":"4096",
            "dynamic_th":"3"
        }
    },
{%- endmacro %}

{%- macro generate_queue_buffers(port_names) %}
    "BUFFER_QUEUE": {
{% for port in port_names.split(',') %}
        "{{ port }}|0-2": {
            "profile" : "q_lossy_profile"
        },
{% endfor %}
{% for port in port_names.split(',') %}
        "{{ port }}|3-4": {
            "profile" : "egress_lossless_profile"
        }{% if not loop.last %},{% endif %}
{% endfor %}
    }
{%- endmacro %}
